var util = new NT.utilObj.util();
var loginUserName;
var orgCode;
var orgPath;
var orgName;
var orgId;
/*
 * 用户列表显示
 */
var queryGridUrl = "../loan/findByCondition.action";

var addDataUrl = "../loan/addLoan.action";
//补件
var supplyDataUrl = "../loan/loanResubmitComplete.action";

var editDataUrl = "../loan/updateLoan.action";
//var editDataUrl = "../loan/updateLoan.action";
var removeDataUrl = "../firm/delFirm.action";
var turnDataUrl='../loan/loanWorkTransfer.action';
var userOptionUrl = "../user/queryUserOptions.action";

/*
 *查询用户资料 
 */
var querDetialUrl = "../loan/findById.action";

var nowOperate;

var store_old={};
var store_new={};
function compareStore(){
	var returnValue=1;
	$.each(store_new,function(key,ele){
			
			var valueOld=store_old[key];
			if(ele!=valueOld){
				returnValue=0;
			}
		}
	);
	return returnValue;
}

function sortArr(arr){
	for(var i=0;i<arr.length;i++){
		for(var j=i+1;j<arr.length;j++){
			if(arr[i]>arr[j]){
				var temp=arr[i];
				arr[i]=arr[j];
				arr[j]=temp;
			}
		}
	}
	return arr;
}

/**
 * 加载数据
 */
var loadData = function(){
	var headParam = [];
	//headParam.push("id");
	
	headParam.push("loanId");
	headParam.push("initTime");
	//业务种类
	headParam.push("loanType");
	//申贷金额
	headParam.push("loanAmount");
	//贷款期限
	headParam.push("loanTerm");
	//贷款人
	headParam.push("borrowerName");
	//处理进度
	headParam.push("processStat");
	//处理人
	headParam.push("curProcessHandler");
	//处理人批复意见
	headParam.push("curProcessFeedback");
	//进度更新日期
	headParam.push("curProcessUpdateTime");
	
	
	var url = queryGridUrl;
	
	var defaultBtns = {"viewBtn":"show","editBtn":"show","removeBtn":"hidden"};
	var operateBtns = [];
	var supplyBtn = {'btnName':'supplyBtn','text':'<button class="btn btn-sm btn-warning" onclick="supply(this)" title="补件">' +
			' <i class="glyphicon glyphicon-edit"></i>' +
			'</button>'};
	var historyBtn = {'btnName':'historyBtn','text':'<button class="btn btn-sm btn-info" onclick="showHistory(this)" title="查看历史">' +
			' <i class="glyphicon glyphicon-inbox"></i>' +
			'</button>'};
	operateBtns.push(supplyBtn);
	operateBtns.push(historyBtn);
	var querParam = getQueryGridParam();
	if(querParam!=null)
	{
		var gridObj = {};
		gridObj["url"] = url;
		gridObj["headParam"] = headParam;
		gridObj["queryParam"] = querParam;
		gridObj["defaultBtns"] = defaultBtns;
		gridObj["operateBtns"] = operateBtns;
		gridObj["pk"] = "loanId";
		//如果需要获取列表中其余字段值
		gridObj["columnValue"] = "processStat";
		gridObj["page"] = true;
		//gridObj["checked"]=false;
		gridObj["xuhao"]=true;
		
		/*var statusFormat = function(val){
			if(val=="ASSIGNED"){
				return "已分配独立审查人，等待审查";
			}
			else if(val=="WAIT"){
				return "等待上报";
			}
			else if(val=="SUBMIT"){
				return "已上报等待分配";
			}
			else if(val=="EXAMINE_SUCC_LIANSHE"){
				return "通过审查，等待区联社审批";
			}
			else if(val=="EXAMINE_SUCC_GEJING"){
				return "通过审查，等待个金审批";
			}
			else if(val=="EXAMINE_UPDATE"){
				return "审查失败，需要补件";
			}
			else if(val=="EXAMINE_FAIL"){
				return "审查失败，退件";
			}
			else if(val=="APPROVAL_SUCC_LIANSHE"){
				return "审批成功";
			}
			else if(val=="APPROVAL_SUCC_GEJING"){
				return "审批成功";
			}
			else if(val=="APPROVAL_FAIL_LIANSHE"){
				return "审批失败，退件";
			}
			else if(val=="APPROVAL_FAIL_GEJING"){
				return "审批失败，退件";
			}
			else {
				return val;
			}
			//return "";
		};
		
		var headFormat = {"processStat":statusFormat};
		gridObj["headFormat"] = headFormat;*/
		
		var nTGridBean = new NTGridBean();
		nTGridBean.init(gridObj);
		nTGridBean.loadGrid();
	}
};


/**
 * 获得pk
 */
var getPk = function(btn){
	var pk = $(btn).parent().parent().parent().attr("pk");
	return pk;
};
/**
 * 获得columnValue
 */
var getColumn = function(btn){
	var columnValue = $(btn).parent().parent().parent().attr("columnValue");
	return columnValue;
};

/**
 * 显示模态框
 */
var  showModel = function(){
	resetAddOrEditForm();
	$("#addOrEditModal").modal("show");
	if(nowOperate=="add"||nowOperate=="edit")
	{
		$("#jkrqs").hide();
		$("#dbrqs").hide();
		$("#qtqs").hide();
		$("#qtbc").hide();
	}
//	AddOrEditCheck();
};

/**
 * 关闭模态框
 */
var hideModel = function(){
	$("#addOrEditModal").modal("hide");
};

/**
 * 清空form
 */
var resetAddOrEditForm = function(){
	$("#addOrEditForm")[0].reset();
	$('span[id="errormsg"]').remove();
	//隐藏配偶姓名和配偶身份证框
	$("#spouseInfo").hide();
	//隐藏备注框
	/*$("#syfRe").hide();
	$("#xfkdRe").hide();
	$("#jydkRe").hide();
	$("#nhxexydkRe").hide();
	$("#esfajRe").hide();*/
	
	//
	//$("input[name='businessTypes']").attr("checked",false);
	//$("input[name='businessTypes']").removeAttr("checked");
	
	
};

/**
 * 新增或修改成功之后的事件
 * @return
 */
var addOrEditCompleteFun = function(){
	hideModel();
	loadData();
};


/**
 * 新增
 * @return
 */
var addData = function(param){
	operateUtil.addData(addDataUrl,param,addOrEditCompleteFun);
};

/**
 * 详情
 */
var viewData = function(param,viewSuccessFun){
	operateUtil.viewData(querDetialUrl,param,viewSuccessFun);
};

/**
 *编辑
 */
var editData = function(param){
	operateUtil.editData(editDataUrl,param,addOrEditCompleteFun);
};

/**
 *补件
 */
var supplyData = function(param){
	operateUtil.editData(supplyDataUrl,param,addOrEditCompleteFun);
};


/**
 * 删除
 */
var removeData = function(param){
	operateUtil.removeData(removeDataUrl,param,addOrEditCompleteFun);
};



/**
 * 删除
 */
/*var removeBtn = function(btn){
	var pk = getPk(btn);
	
	util.emmAjax({
		url : querDetialUrl,
		data:{'firmNum':pk},
		type : 'post',
		success : function(data) {
			var obj = util.str2Json(data);
			var firmObj=obj.data;
			if(obj.success=='true')
				{
					var param='{'
						param=param+('\"firmNum\":\"'+firmObj.firmNum+ '\",');
						param=param+('\"firmName\":\"'+firmObj.firmName+ '\",');
						param=param+('\"contact\":\"'+firmObj.firmContact+ '\",');
						param=param+('\"telephone\":\"'+firmObj.telephone+ '\",');
						param=param+('\"mobilePhone\":\"'+firmObj.mobilePhone+ '\",');
						param=param+('\"fax\":\"'+firmObj.fax+ '\",');
						param=param+('\"email\":\"'+firmObj.email+ '\",');
						param=param+('\"address\":\"'+firmObj.address+ '\",');
						param=param+('\"firmDate\":\"'+firmObj.firmDate+ '\",');
						param=param+('\"remark\":\"'+firmObj.remark+ '\"');
					
						param += '}';
						param=str2Json(param);
					removeData(param);
				}
			else{
				util.sysAlert(obj.data);
			}
			
		}
	});
};*/



/**
 * 编辑回填
 */
var editDataFill=function(pk){
	var param = {"loanId":pk};
	viewData(param,dataFill);
};

/**
 * 编辑
 */
var editBtn = function(btn){
	var pk = getPk(btn);
	var processStat = getColumn(btn);
	if(processStat=="等待上报")
	{
		nowOperate = "edit";
		$("#action").html('编辑贷款申请');
		showModel();
		//$("#addFirmNum").attr("disabled",true);
		editDataFill(pk);
	}
	else
	{
		util.sysAlert("只有状态为[等待上报]的记录可以修改！");
	}

	
	
};

/**
 * 补件
 */
var supply = function(btn){
	var pk = getPk(btn);
	var processStat = getColumn(btn)
	//判断当前记录processStat为补件，否则提示不可补件
	if(processStat=="审查失败，需要补件")
	{
		nowOperate = "supply";
		$("#action").html('贷款申请补件');
		showModel();
		//$("#addFirmNum").attr("disabled",true);
		editDataFill(pk);
	}
	else
	{
		/*var processStatDesc="";
		if(processStat=="ASSIGNED"){
			processStatDesc="已分配独立审查人，等待审查";
		}
		else if(processStat=="WAIT"){
			processStatDesc="等待上报";
		}
		else if(processStat=="SUBMIT"){
			processStatDesc="已上报等待分配";
		}
		else if(processStat=="EXAMINE_SUCC_LIANSHE"){
			processStatDesc="通过审查，等待区联社审批";
		}
		else if(processStat=="EXAMINE_SUCC_GEJING"){
			processStatDesc="通过审查，等待个金审批";
		}
		else if(processStat=="EXAMINE_UPDATE"){
			processStatDesc="审查失败，需要补件";
		}
		else if(processStat=="EXAMINE_FAIL"){
			processStatDesc="审查失败，退件";
		}
		else if(processStat=="APPROVAL_SUCC_LIANSHE"){
			processStatDesc="审批成功";
		}
		else if(processStat=="APPROVAL_SUCC_GEJING"){
			processStatDesc="审批成功";
		}
		else if(processStat=="APPROVAL_FAIL_LIANSHE"){
			processStatDesc="审批失败，退件";
		}
		else if(processStat=="APPROVAL_FAIL_GEJING"){
			processStatDesc="审批失败，退件";
		}*/
		util.sysAlert("当前申请进度为["+processStat+"],不允许补件！");
	}
	
};

/**
 * 查看历史
 */
var showHistory = function(btn){
	var id = getPk(btn);
	var loanId = getPk(btn)
	var url = "../loanAppHistory/detailsLoanAppHistory.html?loanId="+loanId+"&loginUserName="+loginUserName;
	window.location.href = encodeURI(url);
};

var turnBtn=function(){
	//var param = getRemoveDataOfNumbersParam();
	var param = getTurnDataOfNumbersParam();
	if(param!=undefined){
		var util = new NT.utilObj.util();
		//removeDataOfNumbers(param);
		util.confirmView(function(){
			util.emmAjax({
				url : turnDataUrl,
				data: param,
				success : function(data) {
					var obj = eval('(' + data + ')');
					if(obj.success=='true')
					{
						util.sysAlert("转交成功！");
						loadData();	
					}
					else{
						util.sysAlert(obj.data);
					}
					/*if(obj.success=='true')
					{
						
					}
					else{
						util.sysAlert(obj.data);
					}*/
				}
			});
		},"确定转给他人处理？");
		
		
	}
};

/**
 * 获得批量转交的参数
 * @return
 */
var getTurnDataOfNumbersParam = function(){
	var checkboxs = $("#table").find("tbody").find("input[type='checkbox']");
	var pks = new Array();
	
	$(checkboxs).each(function(index,ele){
		if($(this).is(":checked")){
			var pk = getPk($(this).parent());
			pks.push(pk);
		}
	});
	
	if(pks.length>0){
		
		var customerManager = $("#query_customerManage").val();
		//alert(customerManager);
		if(customerManager!='')
		{
			var param="{";
			//param=param+('\"curProcessUser\":\"'+customerManager+'\",');
			param=param+('\"operator\":\"'+customerManager+'\",');
			
			for(var i=0;i<pks.length;i++)
				{
					param=param+('\"ids['+i+']\":\"'+pks[i]+'\",');
				}
			param = param.substring(0, param.length - 1);
			param += '}';
			//alert(param);
			param=util.str2Json(param);
			//var param = {"paramNames":pks};
			return param;
		}
		else
		{
			util.sysTips("请选择客户经理！ ","query_customerManage");
		}
		
		
	}
	else{
		util.sysTips("请选择需要转给他人处理的数据！ ","selectremove");
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(function(){
	window.checkForm.openFun().init({path:webPath,form:'addOrEditForm'}); 
	//loadLoginUserInfo();
	
	$("#addRecieveTime").val(GetDateStr(-30));
	$("#addRecieveTime").datetimepicker({
		format: "yyyy-mm-dd",
		autoclose:true,
		minView:2,
		language:'cn'
	});
	
	$("#addBtn").click(function(){
		nowOperate = "add";
		$("#addFirmNum").attr("disabled",false);
		$("#action").html('新增贷款申请');
		showModel();
	});
	
	$("#removeOfNumbersBtn").click(function(){
		var param = getRemoveDataOfNumbersParam();
		if(param!=undefined){
			removeDataOfNumbers(param);
		}
	});
	
	
	$("#addOrEditSaveBtn").click(function(){
		var returnValue=window.checkForm.openFun().onSubmit();
		if(nowOperate=="add"&&returnValue ){
			var param = getAddParam();
			if(param!=undefined){
				addData(param);
			}
		}else if(nowOperate=="edit"&&returnValue ){
			var param = getEditParam();
			if(param!=undefined){
				var returnValue=compareStore();
				if(returnValue==0){
					if(param!=null){
						editData(param);
					}
				}else{
					util.sysAlert("您尚未更改任何内容，保存失败！");
				}
			}
		}else if(nowOperate=="supply"&&returnValue ){
			var param = getEditParam();
			if(param!=undefined){
				//var returnValue=compareStore();
				//if(returnValue==0){
					//if(param!=null){
					//补件不需要判断申请信息是否修改
						supplyData(param);
				//	}
				//}else{
				//	util.sysAlert("您尚未更改任何内容，保存失败！");
				//}
			}
		}

	});
	
	$("#queryGridBtn").click(function(){
		loadData();
	});
	$("#upload").click(function(){
		$("#upload_form").submit();
	});
	//loadData();
	//查询条件：当前用户需要从后台获取
	getLoginInfoAndLoadData();
	
	//配偶信息动态显示
	$('#addIsMaryed').change( function(){
		var isMaryed=$(this).val();
		//切换时清除配偶内容
		//alert(item);
		$("#addSpouseName").val();
		$("#addSpouseCredentialNo").val();
		if(isMaryed=='是')
		{
			$("#spouseInfo").show();
		}
		else if(isMaryed=='否')
		{
			$("#spouseInfo").hide();
		}
	});
	
	//第几套房信息根据是否选择了车位动态显示
	$('#addSyfRemark2').change( function(){
		var syfRemark2=$(this).val();
		//切换时清除配偶内容
		//alert(item);
		$("#addHouseNum").val(0);
		
		if(syfRemark2=='2')
		{
			$("#houseNumDiv").show();
		}
		else if(syfRemark2=='1')
		{
			$("#houseNumDiv").hide();
		}
	});
	
	
	$('input:radio[name="businessTypes"]').change( function(){
		var item = $("input[name='businessTypes']:checked").val();
		//切换时清除备注内容
		//alert(item);
		$("#addYsfRemark1").val(0);
		$("#addYszfRemark2").val(0);
		$("#addSyfRemark2").val(0);
		$("#addEsfRemark").val(0);
		$("#addXfdkRemark").val(0);
		$("#addJydkRemark1").val(0);
		$("#addSyryRemark2").val(0);
		$("#addDmfbRemark2").val(0);
		
		/*$("#addArea").val("");
		$("#addAmout").val("");
		$("#addHouseNum").val(0);
		$("#addIncome").val("");
		$("#addPayPerMonth").val("");*/
		if(item=='1')
		{
			$("#ysfRe").show();
			$("#esfRe").hide();
			$("#xfdkRe").hide();
			$("#jydkRe").hide();
			$("#yisfAndEsfAddInfo").show();
			$("#houseNumDiv").show();
		}
		else if(item=='2')
		{
			$("#ysfRe").hide();
			$("#esfRe").show();
			$("#xfdkRe").hide();
			$("#jydkRe").hide();
			$("#yisfAndEsfAddInfo").show();
			$("#houseNumDiv").show();
		
		}else if(item=='3')
		{
			$("#ysfRe").hide();
			$("#esfRe").hide();
			$("#xfdkRe").show();
			$("#jydkRe").hide();
			$("#yisfAndEsfAddInfo").hide();
			$("#houseNumDiv").hide();
		
		}else if(item=='4')
		{
			$("#ysfRe").hide();
			$("#esfRe").hide();
			$("#xfdkRe").hide();
			$("#jydkRe").show();
			$("#yisfAndEsfAddInfo").hide();
			$("#houseNumDiv").hide();
		
		}else if(item=='5')
		{
			$("#ysfRe").hide();
			$("#esfRe").hide();
			$("#xfdkRe").hide();
			$("#jydkRe").hide();
			$("#yisfAndEsfAddInfo").hide();
			$("#houseNumDiv").hide();
		
		}
	});
	
	$('#addYsfRemark1').change( function(){
		var item=$(this).children('option:selected').val();//这就是selected的值
		//切换时清除备注内容
		//alert(item);
		$("#addYszfRemark2").val(0);
		$("#addSyfRemark2").val(0);
		
		if(item=='1')
		{
			$("#yszfRe").show();
			$("#syfRe").hide();
			$("#houseNumDiv").show();
		}
		else if(item=='2')
		{
			$("#yszfRe").hide();
			$("#syfRe").show();
			$("#houseNumDiv").show();
		}
		else if(item=='3')
		{
			$("#yszfRe").hide();
			$("#syfRe").hide();
			$("#houseNumDiv").show();
		}
	});
	$('#addJydkRemark1').change( function(){
		var item=$(this).children('option:selected').val();//这就是selected的值
		//切换时清除备注内容
		//alert(item);
		$("#addSyryRemark2").val(0);
		$("#addDmfbRemark2").val(0);
		
		if(item=='2')
		{
			$("#syryRe").show();
			$("#dmfbRe").hide();
		}
		else if(item=='3')
		{
			$("#syryRe").hide();
			$("#dmfbRe").show();
		}else
		{
			$("#syryRe").hide();
			$("#dmfbRe").hide();
		}
	});
	
	customerManager_query();
	
	/* $('.selectpicker').selectpicker({
         'selectedText': 'cat'
     });*/
	$(".selectpicker").selectpicker({  
        noneSelectedText : '请选择' ,
        liveSearch:true,
        size: 10
    });  

    $(window).on('load', function() {  
        $('.selectpicker').selectpicker('val', '');  
        $('.selectpicker').selectpicker('refresh');  
    });  
});

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function loadLoginUserInfo() {
	var util = new NT.utilObj.util();
	util.emmAjax({
		url : '../login/getLoginUserInfo.action',
		success : function(data) {
			var obj = eval('(' + data + ')');
			loginUserName = obj.data.userName;
			orgCode = obj.data.orgCode;
			orgPath = obj.data.orgPath;
			orgName = obj.data.orgName;
			orgId = obj.data.orgId;
			
		}
	});
};



function customerManager_query() {
	
	var util = new NT.utilObj.util();
	util.emmAjax({
		url : userOptionUrl,
		data:{'roleName' : '客户经理'},
		success : function(data) {
			var obj = eval('(' + data + ')');
			var userList=obj.data;
			var select = $("#query_customerManage");  
            for (var i = 0; i < userList.length; i++) {  
                select.append("<option value='"+userList[i].userName+"'>"  
                        + userList[i].realName + "（"+ userList[i].userName +"）</option>");  
            }  
            $('.selectpicker').selectpicker('val', '');  
            $('.selectpicker').selectpicker('refresh'); 
		}
	});
	/*var param={
			'roleName' : '客户经理'
			
		};
	var selectObj = {};
	selectObj["url"] = userOptionUrl;
	selectObj["id"] = 'query_customerManager';
	selectObj["param"] = param;
	selectObj["valueParam"] = 'userName';
	selectObj["htmlParam"] = 'realName';
	selectObj["defaultSelectedValue"] = null;
	var selectOption = new SelectOption();
	selectOption.clear('query_customerManager');
	selectOption.loadOption(selectObj);*/
};

function getLoginInfoAndLoadData() {
	var util = new NT.utilObj.util();
	util.emmAjax({
		url : '../login/getLoginUserInfo.action',
		success : function(data) {
			var obj = eval('(' + data + ')');
			loginUserName = obj.data.userName;
			orgCode = obj.data.orgCode;
			orgPath = obj.data.orgPath;
			orgName = obj.data.orgName;
			orgId = obj.data.orgId;
			loadData();
			
		}
	});
};


/**
 * 详情
 */
var viewBtn = function(btn){
	var loanId = getPk(btn);
	var url = "../loanAppDetails/detailsLoanApp.html?loanId=" + loanId;
	//var url ="../UI/css/checkboxAndRedio/index.html"
	window.location.href = encodeURI(url);
};


/**
 * 获得查询列表参数
 */
var getQueryGridParam = function(){
	var QNum = $("#query_loanId").val();
	var QType =$("#query_bussniessType").val()=="0"?"":$("#query_bussniessType").val();
	var QStat =$("#query_processStat").val()=="0"?"":$("#query_processStat").val();
	var QName = $("#query_borrowName").val();
	var startTime=$("#statisticStartTime").val();
	//var endTime=getFormatDateStr($("#statisticEndTime").val(),1);
	var endTime=$("#statisticEndTime").val();
	if(startTime!=""&&endTime=="")
	{
		util.sysTips("开始时间和结束时间必须同时输入","statisticEndTime"); return null;
	}
	else if(startTime==""&&endTime!="")
	{
		util.sysTips("开始时间和结束时间必须同时输入","statisticStartTime"); return null;
	}
	else if(startTime!=""&&endTime!=""&&endTime<=startTime)
	{util.sysTips("结束时间必须大于开始时间","statisticEndTime"); return null;}
	else{
		var param = {
				'loanId' : QNum,
				'loanType' : QType,
				'processStat' : QStat,
				'borrowerName' : QName,
				'queryStartTime' : startTime,
				'queryEndTime' : endTime
				//'operator' : loginUserName//,
				//'curProcessName':'提交申请'
			};
		return param;
	}
};

$("#statisticStartTime").datetimepicker({
	format: "yyyy-mm-dd",
	autoclose:true,
	startView: 2,
	minView: 2,
	language:'cn'
});
$("#statisticEndTime").datetimepicker({
	format: "yyyy-mm-dd",
	autoclose:true,
	startView: 2,
	minView: 2,
	language:'cn'
});
/**
 * 获得增加的参数
 * @return
 */
var getAddParam = function(){
	var addBorrowerName = $("#addBorrowerName").val();
	var addIsMaryed = $("#addIsMaryed").val();
	var addSpouseName = $("#addSpouseName").val();
	var addSpouseCredentialNo=$("#addSpouseCredentialNo").val();
	var addSex = $("#addSex").val();
	
    var addCredentialNo = $("#addCredentialNo").val();
    //var addBusinessTypes = $("#addBusinessTypes").val();
	var addBusinessTypes = $("input[name='businessTypes']:checked").val();
	var addAmount = $("#addAmount").val();
	var addTerm = $("#addTerm").val();
	var addGuaranteeMethod = $("input[name='guaranteeMethod']:checked").val();
	var addIsRenew = $("input[name='isRenew']:checked").val();
	var addMarketer = $("#addMarketer").val();
	var addMarketerPost = $("#addMarketerPost").val();
	var addOperator = $("#addOperator").val();
	var addOperatorPost = $("#addOperatorPost").val();
	
	/*$("#addYsfRemark1").val(0);
	$("#addYszfRemark2").val(0);
	$("#addSyfRemark2").val(0);
	$("#addEsfRemark").val(0);
	$("#addXfdkRemark").val(0);
	$("#addJydkRemark1").val(0);
	$("#addSyryRemark2").val(0);
	$("#addDmfbRemark2").val(0);*/
	var addYsfRemark1 = $("#addYsfRemark1").val();
	var addYszfRemark2 = $("#addYszfRemark2").val();
	var addSyfRemark2 = $("#addSyfRemark2").val();
	var addEsfRemark = $("#addEsfRemark").val();
	var addXfdkRemark = $("#addXfdkRemark").val();
	var addJydkRemark1 = $("#addJydkRemark1").val();
	var addSyryRemark2 = $("#addSyryRemark2").val();
	var addDmfbRemark2 = $("#addDmfbRemark2").val();

	var addRepaymentMethod = $("#addRepaymentMethod").val();
	var addRecieveTime = $("#addRecieveTime").val();
	
	var addArea = $("#addArea").val();
	var addHouseAmount = $("#addHouseAmount").val();
	var addHouseNum = $("#addHouseNum").val();
	var addIncome = $("#addIncome").val();
	var addPayPerMonth = $("#addPayPerMonth").val();
	var businessSubType="";
	if(addSex=='0'){
		util.sysTips("性别不能为空！","addSex");
		return ;
	}
	else if(addIsMaryed=='0')
	{
		util.sysTips("是否已婚不能为空！","addIsMaryed");
		return ;
	}
	else if(addIsMaryed=="是"&&(addSpouseName==null||addSpouseName==""))
	{
		util.sysTips("配偶姓名不能为空！","addSpouseName");
		return ;
	}
	else if(addIsMaryed=="是"&&(addSpouseCredentialNo==null||addSpouseCredentialNo==""))	
	{
		util.sysTips("配偶证件号不能为空！","addSpouseCredentialNo");
		return ;
	}	
	
	else if(typeof(addBusinessTypes)=="undefined")
	{
		util.sysTips("业务类型不能为空！","addBusinessTypes");
		return ;
	}
	else if(addRepaymentMethod=='0'){
		util.sysTips("还款方式不能为空！","addRepaymentMethod");
		return ;
	}
	else if(addRecieveTime==''){
		util.sysTips("收件时间不能为空！","addRecieveTime");
		return ;
	}
	else if(typeof(addGuaranteeMethod)=="undefined")
	{
		util.sysTips("担保方式不能为空！","addGuaranteeMethod");
		return ;
	}
	else if(typeof(addIsRenew)=="undefined")
	{
		util.sysTips("是否续贷不能为空！","addIsRenew");
		return ;
	}
	else if(addMarketerPost=='0'){
		util.sysTips("营销人岗位不能为空！","addMarketerPost");
		return ;
	}
	else if(addOperatorPost=='0'){
		util.sysTips("经办人岗位不能为空！","addOperatorPost");
		return ;
	}
	else
	{
		if(addBusinessTypes=='1')
		{
			addYsfRemark1 = $("#addYsfRemark1").val();
			//一手住房
			if(addYsfRemark1=='1')
			{
				addYszfRemark2 = $("#addYszfRemark2").val();
				if(addYszfRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addYszfRemark2");
					return ;
				}
			}
			//商用房
			else if(addYsfRemark1=='2'){
				addSyfRemark2 = $("#addSyfRemark2").val();
				if(addSyfRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addSyfRemark2");
					return ;
				}
				
			}
			else if(addYsfRemark1=='0')
			{
				util.sysTips("备注1不能为空！","addYsfRemark1");
				return ;
			}
			
			//当非车位时需要校验第几套房
			if(addSyfRemark2!='1')
			{
				if(addHouseNum=='0'){
					util.sysTips("第几套房不能为空！","addHouseNum");
					return ;
				}
			}
			
			
		}
		else if(addBusinessTypes=='2')
		{
			addEsfRemark = $("#addEsfRemark").val();
			if(addEsfRemark=='0')
			{
				util.sysTips("备注不能为空！","addEsfRemark");
				return ;
			}
			
		
		}else if(addBusinessTypes=='3')
		{
			addXfdkRemark = $("#addXfdkRemark").val();
			if(addXfdkRemark=='0')
			{
				util.sysTips("备注不能为空！","addXfdkRemark");
				return ;
			}
			
		}else if(addBusinessTypes=='4')
		{
			addJydkRemark1 = $("#addJydkRemark1").val();
			//失业人员小额担保贷款
			if(addJydkRemark1=='2')
			{
				addSyryRemark2 = $("#addSyryRemark2").val();
				if(addSyryRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addSyryRemark2");
					return ;
				}
			}
			//“贷免扶补”创业小额贷款
			else if(addJydkRemark1=='3'){
				addDmfbRemark2 = $("#addDmfbRemark2").val();
				if(addDmfbRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addDmfbRemark2");
					return ;
				}
			}
			else if(addJydkRemark1=='0')
			{
				util.sysTips("备注1不能为空！","addJydkRemark1");
				return ;
			}
			
		}else if(addBusinessTypes=='5')
		{
			
		}
		//参数需要传递到loanBean的loanInfo中
		
		var param='{';
		param=param+('\"operator\":\"'+loginUserName+ '\",');
		param=param+('\"orgId\":\"'+orgId+ '\",');
		//param=param+('\"orgName\":\"'+orgName+ '\",');
		//param=param+('\"orgCode\":\"'+orgCode+ '\",');
		param=param+('\"LoanAmount\":\"'+addAmount+ '\",');
		param=param+('\"LoanTerm\":\"'+addTerm+ '\",');
		param=param+('\"pickupTime\":\"'+addRecieveTime+ '\",');
		//param=param+('\"pickupTime\":\"'+addBusinessTypes+ '\",');
		param=param+('\"loanInfo.borrowerName\":\"'+addBorrowerName+ '\",');
		param=param+('\"loanInfo.isMaryed\":\"'+addIsMaryed+ '\",');
		if(addIsMaryed=="是")
		{
			param=param+('\"loanInfo.spouseName\":\"'+addSpouseName+ '\",');
			param=param+('\"loanInfo.spouseCredentialNo\":\"'+addSpouseCredentialNo+ '\",');
		}
		param=param+('\"loanInfo.sex\":\"'+addSex+ '\",');
		param=param+('\"loanInfo.credentialNo\":\"'+addCredentialNo+ '\",');
		param=param+('\"loanInfo.businessTypes\":\"'+addBusinessTypes+ '\",');
		if(addBusinessTypes=='1')
		{
			param=param+('\"loanInfo.ysfRemark1\":\"'+addYsfRemark1+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addYsfRemark1+ '\",');
			if(addYsfRemark1=='1')
			{
				param=param+('\"loanInfo.yszfRemark2\":\"'+addYszfRemark2+ '\",');
			}
			else if(addYsfRemark1=='2')
			{
				param=param+('\"loanInfo.syfRemark2\":\"'+addSyfRemark2+ '\",');
			}
			param=param+('\"loanInfo.area\":\"'+addArea+ '\",');
			param=param+('\"loanInfo.houseAmount\":\"'+addHouseAmount+ '\",');
			param=param+('\"loanInfo.income\":\"'+addIncome+ '\",');
			param=param+('\"loanInfo.payPerMonth\":\"'+addPayPerMonth+ '\",');
			//当备注2不是车位时，才上送第几套房
			if(addYszfRemark2!='1')
			{
				param=param+('\"loanInfo.houseNum\":\"'+addHouseNum+ '\",');
			}
			
			
		}
		else if(addBusinessTypes=='2')
		{
			param=param+('\"loanInfo.esfRemark\":\"'+addEsfRemark+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addEsfRemark+ '\",');
			param=param+('\"loanInfo.area\":\"'+addArea+ '\",');
			param=param+('\"loanInfo.houseAmount\":\"'+addHouseAmount+ '\",');
			param=param+('\"loanInfo.houseNum\":\"'+addHouseNum+ '\",');
			param=param+('\"loanInfo.income\":\"'+addIncome+ '\",');
			param=param+('\"loanInfo.payPerMonth\":\"'+addPayPerMonth+ '\",');
		
		}else if(addBusinessTypes=='3')
		{
			param=param+('\"loanInfo.xfdkRemark\":\"'+addXfdkRemark+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addXfdkRemark+ '\",');
		
		}else if(addBusinessTypes=='4')
		{
			param=param+('\"loanInfo.jydkRemark1\":\"'+addJydkRemark1+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addJydkRemark1+ '\",');
			if(addJydkRemark1=='2')
			{
				param=param+('\"loanInfo.syryRemark2\":\"'+addSyryRemark2+ '\",');
			}
			else if(addJydkRemark1=='3')
			{
				param=param+('\"loanInfo.dmfbRemark2\":\"'+addDmfbRemark2+ '\",');
			}
		
		}else if(addBusinessTypes=='5')
		{
			
		}
		param=param+('\"loanInfo.amount\":\"'+addAmount+ '\",');
		param=param+('\"loanInfo.term\":\"'+addTerm+ '\",');
		param=param+('\"loanInfo.guaranteeMethod\":\"'+addGuaranteeMethod+ '\",');
		param=param+('\"loanInfo.repaymentMethod\":\"'+addRepaymentMethod+ '\",');
		param=param+('\"loanInfo.recieveTime\":\"'+addRecieveTime+ '\",');
		param=param+('\"loanInfo.isRenew\":\"'+addIsRenew+ '\",');
		param=param+('\"loanInfo.marketer\":\"'+addMarketer+ '\",');
		param=param+('\"loanInfo.marketerPost\":\"'+addMarketerPost+ '\",');
		param=param+('\"loanInfo.operator\":\"'+addOperator+ '\",');
		param=param+('\"loanInfo.operatorPost\":\"'+addOperatorPost+ '\"');
		//param = param.substring(0, param.length - 1);
		param += '}';
		//alert(param);
		param=str2Json(param);
		return param;
	}
};

/**
 * 获得编辑的参数
 * @return
 */
var getEditParam = function(){
	var loanId = $("#addLoanId").val();
	var addBorrowerName = $("#addBorrowerName").val();
	var addIsMaryed = $("#addIsMaryed").val();
	var addSpouseName = $("#addSpouseName").val();
	var addSpouseCredentialNo=$("#addSpouseCredentialNo").val();
	var addSex = $("#addSex").val();
    var addCredentialNo = $("#addCredentialNo").val();
    //var addBusinessTypes = $("#addBusinessTypes").val();
	var addBusinessTypes = $("input[name='businessTypes']:checked").val();
	
	var addAmount = $("#addAmount").val();
	var addTerm = $("#addTerm").val();
	var addGuaranteeMethod = $("input[name='guaranteeMethod']:checked").val();
	var addIsRenew = $("input[name='isRenew']:checked").val();
	var addMarketer = $("#addMarketer").val();
	var addMarketerPost = $("#addMarketerPost").val();
	var addOperator = $("#addOperator").val();
	var addOperatorPost = $("#addOperatorPost").val();
	
	var addYsfRemark1 = $("#addYsfRemark1").val();
	var addYszfRemark2 = $("#addYszfRemark2").val();
	var addSyfRemark2 = $("#addSyfRemark2").val();
	var addEsfRemark = $("#addEsfRemark").val();
	var addXfdkRemark = $("#addXfdkRemark").val();
	var addJydkRemark1 = $("#addJydkRemark1").val();
	var addSyryRemark2 = $("#addSyryRemark2").val();
	var addDmfbRemark2 = $("#addDmfbRemark2").val();
	
	var addRepaymentMethod = $("#addRepaymentMethod").val();
	var addRecieveTime = $("#addRecieveTime").val();
	
	var addArea = $("#addArea").val();
	var addHouseAmount = $("#addHouseAmount").val();
	var addHouseNum = $("#addHouseNum").val();
	var addIncome = $("#addIncome").val();
	var addPayPerMonth = $("#addPayPerMonth").val();
	
/*	var addSyfRemark1 = $("#addSyfRemark1").val();
	var addSyfRemark2 = $("#addSyfRemark2").val();
	var addXfdkRemark = $("#addXfdkRemark").val();
	var addJydkRemark1 = $("#addJydkRemark1").val();
	var addJydkRemark2 = $("#addJydkRemark2").val();
	var addNhxexydkRemark = $("#addNhxexydkRemark").val();
	var addEsfajRemark = $("#addEsfajRemark").val();*/
	
	if(addSex=='0'){
		util.sysTips("性别不能为空！","addSex");
		return ;
	}
	else if(addIsMaryed=='0')
	{
		util.sysTips("是否已婚不能为空！","addIsMaryed");
		return ;
	}
	else if(addIsMaryed=="是"&&(addSpouseName==null||addSpouseName==""))
	{
		util.sysTips("配偶姓名不能为空！","addSpouseName");
		return ;
	}
	else if(addIsMaryed=="是"&&(addSpouseCredentialNo==null||addSpouseCredentialNo==""))	
	{
		util.sysTips("配偶证件号不能为空！","addSpouseCredentialNo");
		return ;
	}	
	else if(typeof(addBusinessTypes)=="undefined")
	{
		util.sysTips("业务类型不能为空！","addBusinessTypes");
		return ;
	}
	else if(addRepaymentMethod=='0'){
		util.sysTips("还款方式不能为空！","addRepaymentMethod");
		return ;
	}
	else if(addRecieveTime==''){
		util.sysTips("收件时间不能为空！","addRecieveTime");
		return ;
	}
	else if(typeof(addGuaranteeMethod)=="undefined")
	{
		util.sysTips("担保方式不能为空！","addGuaranteeMethod");
		return ;
	}
	else if(typeof(addIsRenew)=="undefined")
	{
		util.sysTips("是否续贷不能为空！","addIsRenew");
		return ;
	}
	else if(addMarketerPost=='0'){
		util.sysTips("营销人岗位不能为空！","addMarketerPost");
		return ;
	}
	else if(addOperatorPost=='0'){
		util.sysTips("经办人岗位不能为空！","addOperatorPost");
		return ;
	}
	else
	{/*
		
		if(addBusinessTypes=='1')
		{
			addYsfRemark1 = $("#addYsfRemark1").val();
			addSyfRemark2 = $("#addSyfRemark2").val();
		}
		else if(addBusinessTypes=='2')
		{
			addXfdkRemark=$("#addXfdkRemark").val();
		
		}else if(addBusinessTypes=='3')
		{
			addJydkRemark1=$("#addJydkRemark1").val();
			addJydkRemark2=$("#addJydkRemark2").val();
		}else if(addBusinessTypes=='4')
		{
			addNhxexydkRemark=$("#addNhxexydkRemark").val();
			
		}else if(addBusinessTypes=='5')
		{
			addEsfajRemark=$("#addEsfajRemark").val();
		}
		
		var param='{';
		param=param+('\"operator\":\"'+loginUserName+ '\",');
		param=param+('\"orgId\":\"'+orgId+ '\",');
		param=param+('\"loanId\":\"'+loanId+ '\",');
		//param=param+('\"loanInfo\":[{');
		param=param+('\"loanInfo.borrowerName\":\"'+addBorrowerName+ '\",');
		param=param+('\"loanInfo.spouseName\":\"'+addSpouseName+ '\",');
		param=param+('\"loanInfo.sex\":\"'+addSex+ '\",');
		param=param+('\"loanInfo.credentialNo\":\"'+addCredentialNo+ '\",');
		param=param+('\"loanInfo.businessTypes\":\"'+addBusinessTypes+ '\",');
		if(addBusinessTypes=='1')
		{
			param=param+('\"loanInfo.syfRemark1\":\"'+addSyfRemark1+ '\",');
			param=param+('\"loanInfo.syfRemark2\":\"'+addSyfRemark2+ '\",');
		}
		else if(addBusinessTypes=='2')
		{
			param=param+('\"loanInfo.xfdkRemark\":\"'+addXfdkRemark+ '\",');
		
		}else if(addBusinessTypes=='3')
		{
			param=param+('\"loanInfo.jydkRemark1\":\"'+addJydkRemark1+ '\",');
			param=param+('\"loanInfo.jydkRemark2\":\"'+addJydkRemark2+ '\",');
		
		}else if(addBusinessTypes=='4')
		{
			param=param+('\"loanInfo.nhxexydkRemark\":\"'+addNhxexydkRemark+ '\",');
		
		}else if(addBusinessTypes=='5')
		{
			param=param+('\"loanInfo.esfajRemark\":\"'+addEsfajRemark+ '\",');
		}
		param=param+('\"loanInfo.amount\":\"'+addAmount+ '\",');
		param=param+('\"loanInfo.term\":\"'+addTerm+ '\",');
		param=param+('\"loanInfo.guaranteeMethod\":\"'+addGuaranteeMethod+ '\",');
		param=param+('\"loanInfo.isRenew\":\"'+addIsRenew+ '\",');
		param=param+('\"loanInfo.marketer\":\"'+addMarketer+ '\",');
		param=param+('\"loanInfo.marketerPost\":\"'+addMarketerPost+ '\",');
		param=param+('\"loanInfo.operator\":\"'+addOperator+ '\",');
		param=param+('\"loanInfo.operatorPost\":\"'+addOperatorPost+ '\"');
		//param = param.substring(0, param.length - 1);
		param += '}';
		//alert(param);
		param=str2Json(param);
		store_new['borrowerName']=addBorrowerName;
		store_new['spouseName']=addSpouseName;
		store_new['sex']=addSex;
		store_new['credentialNo']=addCredentialNo;
		store_new['businessType']=addBusinessTypes;
		if(addSyfRemark1=='0')
		{
			store_new['syfRemark1']=null;
		}
		else{
			store_new['syfRemark1']=addSyfRemark1;
		}
		if(addSyfRemark2=="")
		{
			store_new['syfRemark2']=null;
		}
		else{
			store_new['syfRemark2']=addSyfRemark2;
		}
		
		if(addXfdkRemark=='0')
		{
			store_new['xfdkRemark']=null;
		}
		else{
			store_new['xfdkRemark']=addXfdkRemark;
		}
		if(addJydkRemark1=='0')
		{
			store_new['jydkRemark1']=null;
		}
		else{
			store_new['jydkRemark1']=addJydkRemark1;
		}
		if(addJydkRemark2=="")
		{
			store_new['jydkRemark2']=null;
		}
		else{
			store_new['jydkRemark2']=addJydkRemark2;
		}
		
		if(addNhxexydkRemark=='0')
		{
			store_new['nhxexydkRemark']=null;
		}
		else{
			store_new['nhxexydkRemark']=addNhxexydkRemark;
		}
		if(addEsfajRemark=='0')
		{
			store_new['esfajRemark']=null;
		}
		else{
			store_new['esfajRemark']=addEsfajRemark;
		}
		store_new['amount']=addAmount;
		store_new['term']=addTerm;
		store_new['guaranteeMethod']=addGuaranteeMethod;
		store_new['isRenew']=addIsRenew;
		store_new['marketer']=addMarketer;
		store_new['marketerPost']=addMarketerPost;
		store_new['operator']=addOperator;
		store_new['operatorPost']=addOperatorPost;
		return param;
	*/

		if(addBusinessTypes=='1')
		{
			addYsfRemark1 = $("#addYsfRemark1").val();
			//一手住房
			if(addYsfRemark1=='1')
			{
				addYszfRemark2 = $("#addYszfRemark2").val();
				if(addYszfRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addYszfRemark2");
					return ;
				}
			}
			//商用房
			else if(addYsfRemark1=='2'){
				addSyfRemark2 = $("#addSyfRemark2").val();
				if(addSyfRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addSyfRemark2");
					return ;
				}
			}
			else if(addYsfRemark1=='0')
			{
				util.sysTips("备注1不能为空！","addYsfRemark1");
				return ;
			}
			//当非车位时需要校验第几套房
			if(addSyfRemark2!='1')
			{
				if(addHouseNum=='0'){
					util.sysTips("第几套房不能为空！","addHouseNum");
					return ;
				}
			}
		}
		else if(addBusinessTypes=='2')
		{
			addEsfRemark = $("#addEsfRemark").val();
			if(addEsfRemark=='0')
			{
				util.sysTips("备注不能为空！","addEsfRemark");
				return ;
			}
		
		}else if(addBusinessTypes=='3')
		{
			addXfdkRemark = $("#addXfdkRemark").val();
			if(addXfdkRemark=='0')
			{
				util.sysTips("备注不能为空！","addXfdkRemark");
				return ;
			}
		}else if(addBusinessTypes=='4')
		{
			addJydkRemark1 = $("#addJydkRemark1").val();
			//失业人员小额担保贷款
			if(addJydkRemark1=='2')
			{
				addSyryRemark2 = $("#addSyryRemark2").val();
				if(addSyryRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addSyryRemark2");
					return ;
				}
			}
			//“贷免扶补”创业小额贷款
			else if(addJydkRemark1=='3'){
				addDmfbRemark2 = $("#addDmfbRemark2").val();
				if(addDmfbRemark2=='0')
				{
					util.sysTips("备注2不能为空！","addDmfbRemark2");
					return ;
				}
			}
			else if(addJydkRemark1=='0')
			{
				util.sysTips("备注1不能为空！","addJydkRemark1");
				return ;
			}
			
		}else if(addBusinessTypes=='5')
		{
			
		}
		
		var param='{';
		param=param+('\"loanId\":\"'+loanId+ '\",');
		param=param+('\"operator\":\"'+loginUserName+ '\",');
		param=param+('\"orgId\":\"'+orgId+ '\",');
		/*param=param+('\"orgName\":\"'+orgName+ '\",');
		param=param+('\"orgCode\":\"'+orgCode+ '\",');*/
		param=param+('\"LoanAmount\":\"'+addAmount+ '\",');
		param=param+('\"LoanTerm\":\"'+addTerm+ '\",');
		param=param+('\"pickupTime\":\"'+addRecieveTime+ '\",');
		//param=param+('\"loanInfo\":[{');
		param=param+('\"loanInfo.borrowerName\":\"'+addBorrowerName+ '\",');
		param=param+('\"loanInfo.isMaryed\":\"'+addIsMaryed+ '\",');
		if(addIsMaryed=="是")
		{
			param=param+('\"loanInfo.spouseName\":\"'+addSpouseName+ '\",');
			param=param+('\"loanInfo.spouseCredentialNo\":\"'+addSpouseCredentialNo+ '\",');
		}
		param=param+('\"loanInfo.sex\":\"'+addSex+ '\",');
		param=param+('\"loanInfo.credentialNo\":\"'+addCredentialNo+ '\",');
		param=param+('\"loanInfo.businessTypes\":\"'+addBusinessTypes+ '\",');
		if(addBusinessTypes=='1')
		{
			param=param+('\"loanInfo.ysfRemark1\":\"'+addYsfRemark1+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addYsfRemark1+ '\",');
			if(addYsfRemark1=='1')
			{
				param=param+('\"loanInfo.yszfRemark2\":\"'+addYszfRemark2+ '\",');
			}
			else if(addYsfRemark1=='2')
			{
				param=param+('\"loanInfo.syfRemark2\":\"'+addSyfRemark2+ '\",');
			}
			param=param+('\"loanInfo.area\":\"'+addArea+ '\",');
			param=param+('\"loanInfo.houseAmount\":\"'+addHouseAmount+ '\",');
			param=param+('\"loanInfo.income\":\"'+addIncome+ '\",');
			param=param+('\"loanInfo.payPerMonth\":\"'+addPayPerMonth+ '\",');
			//当备注2不是车位时，要上送第几套房
			if(addYszfRemark2!='1')
			{
				param=param+('\"loanInfo.houseNum\":\"'+addHouseNum+ '\",');
			}
			
		}
		else if(addBusinessTypes=='2')
		{
			param=param+('\"loanInfo.esfRemark\":\"'+addEsfRemark+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addEsfRemark+ '\",');
			param=param+('\"loanInfo.area\":\"'+addArea+ '\",');
			param=param+('\"loanInfo.houseAmount\":\"'+addHouseAmount+ '\",');
			param=param+('\"loanInfo.houseNum\":\"'+addHouseNum+ '\",');
			param=param+('\"loanInfo.income\":\"'+addIncome+ '\",');
			param=param+('\"loanInfo.payPerMonth\":\"'+addPayPerMonth+ '\",');
		
		}else if(addBusinessTypes=='3')
		{
			param=param+('\"loanInfo.xfdkRemark\":\"'+addXfdkRemark+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addXfdkRemark+ '\",');
		
		}else if(addBusinessTypes=='4')
		{
			param=param+('\"loanInfo.jydkRemark1\":\"'+addJydkRemark1+ '\",');
			//添加业务子类型
			param=param+('\"loanSubType\":\"'+addJydkRemark1+ '\",');
			if(addJydkRemark1=='2')
			{
				param=param+('\"loanInfo.syryRemark2\":\"'+addSyryRemark2+ '\",');
			}
			else if(addJydkRemark1=='3')
			{
				param=param+('\"loanInfo.dmfbRemark2\":\"'+addDmfbRemark2+ '\",');
			}
		
		}else if(addBusinessTypes=='5')
		{
			
		}
		param=param+('\"loanInfo.amount\":\"'+addAmount+ '\",');
		param=param+('\"loanInfo.term\":\"'+addTerm+ '\",');
		param=param+('\"loanInfo.guaranteeMethod\":\"'+addGuaranteeMethod+ '\",');
		param=param+('\"loanInfo.repaymentMethod\":\"'+addRepaymentMethod+ '\",');
		param=param+('\"loanInfo.recieveTime\":\"'+addRecieveTime+ '\",');
		param=param+('\"loanInfo.isRenew\":\"'+addIsRenew+ '\",');
		param=param+('\"loanInfo.marketer\":\"'+addMarketer+ '\",');
		param=param+('\"loanInfo.marketerPost\":\"'+addMarketerPost+ '\",');
		param=param+('\"loanInfo.operator\":\"'+addOperator+ '\",');
		param=param+('\"loanInfo.operatorPost\":\"'+addOperatorPost+ '\"');
		//param = param.substring(0, param.length - 1);
		param += '}';
		//alert(param);
		param=str2Json(param);
		store_new['borrowerName']=addBorrowerName;
		store_new['isMaryed']=addIsMaryed;
		if(addIsMaryed=="是")
		{
			store_new['spouseName']=addSpouseName;
			store_new['spouseCredentialNo']=addSpouseCredentialNo;
		}
		
		store_new['sex']=addSex;
		store_new['credentialNo']=addCredentialNo;
		store_new['businessType']=addBusinessTypes;
		if(addYsfRemark1=='0')
		{
			store_new['ysfRemark1']=null;
		}
		else{
			store_new['ysfRemark1']=addYsfRemark1;
		}
		if(addYszfRemark2=='0')
		{
			store_new['yszfRemark2']=null;
		}
		else{
			store_new['yszfRemark2']=addYszfRemark2;
		}
		
		if(addSyfRemark2=='0')
		{
			store_new['syfRemark2']=null;
		}
		else{
			store_new['syfRemark2']=addSyfRemark2;
		}
		if(addEsfRemark=='0')
		{
			store_new['esfRemark']=null;
		}
		else{
			store_new['esfRemark']=addEsfRemark;
		}
		if(addXfdkRemark=='0')
		{
			store_new['xfdkRemark']=null;
		}
		else{
			store_new['xfdkRemark']=addXfdkRemark;
		}
		
		if(addJydkRemark1=='0')
		{
			store_new['jydkRemark1']=null;
		}
		else{
			store_new['jydkRemark1']=addJydkRemark1;
		}
		if(addSyryRemark2=='0')
		{
			store_new['syryRemark2']=null;
		}
		else{
			store_new['syryRemark2']=addSyryRemark2;
		}
		if(addDmfbRemark2=='0')
		{
			store_new['dmfbRemark2']=null;
		}
		else{
			store_new['dmfbRemark2']=addDmfbRemark2;
		}
		
		
		if(addArea=='')
		{
			store_new['area']=null;
		}
		else{
			store_new['area']=addArea;
		}
		if(addHouseAmount=='')
		{
			store_new['houseAmount']=null;
		}
		else{
			store_new['houseAmount']=addHouseAmount;
		}
		if(addHouseNum=='0')
		{
			store_new['houseNum']=null;
		}
		else{
			store_new['houseNum']=addHouseNum;
		}
		if(addIncome=='')
		{
			store_new['income']=null;
		}
		else{
			store_new['income']=addIncome;
		}
		if(addPayPerMonth=='')
		{
			store_new['payPerMonth']=null;
		}
		else{
			store_new['payPerMonth']=addPayPerMonth;
		}
		if(addRepaymentMethod=='0')
		{
			store_new['repaymentMethod']=null;
		}
		else{
			store_new['repaymentMethod']=addRepaymentMethod;
		}
		if(addRecieveTime=='')
		{
			store_new['receiveTime']=null;
		}
		else{
			store_new['receiveTime']=addRecieveTime;
		}
		/*store_new['area']=addArea;
		store_new['houseAmount']=addHouseAmout;
		store_new['houseNum']=addHouseNum;
		store_new['income']=addIncome;
		store_new['payPerMonth']=addPayPerMonth;*/
		
		store_new['amount']=addAmount;
		store_new['term']=addTerm;
		store_new['guaranteeMethod']=addGuaranteeMethod;
		store_new['isRenew']=addIsRenew;
		store_new['marketer']=addMarketer;
		store_new['marketerPost']=addMarketerPost;
		store_new['operator']=addOperator;
		store_new['operatorPost']=addOperatorPost;
		return param;
	
		}
	
};

/**
 * 编辑回调回填
 * @param data
 * @return
 */
var update_old_data;
var dataFill = function(data){
	
	var obj = util.str2Json(data).data;
	var object = obj.loanInfo
	update_old_data=object;
	
	$("#addLoanId").val(obj.loanId);
	$("#addBorrowerName").val(object.borrowerName);
	$("#addIsMaryed").val(object.isMaryed);
	if(object.isMaryed=="是")
	{
		$("#spouseInfo").show();
		$("#addSpouseName").val(object.spouseName);
		$("#addSpouseCredentialNo").val(object.spouseCredentialNo);
	}
	else if(object.isMaryed=='否')
	{
		$("#spouseInfo").hide();
	}
	
	$("#addSex").val(object.sex);
    $("#addCredentialNo").val(object.credentialNo);
    //$("#addBusinessTypes").val(object.businessType);
    var businessTypeValue = object.businessTypes
    //$('input[type="radio"]:checked').parent('label').addClass('active');
   // $('input[name="addBusinessTypes"]:checked').parent('label').addClass('active');
    $("input[name='businessTypes']").each(function(i){  
        if($(this).val()==businessTypeValue)  
        {  
        	$(this).attr('checked','checked');
            $(this).parent('label').addClass('active');  
        }  
    });
    
 /*   if(item=='1')
	{
		$("#ysfRe").show();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#yisfAndEsfAddInfo").show();
	}
	else if(item=='2')
	{
		$("#ysfRe").hide();
		$("#esfRe").show();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#yisfAndEsfAddInfo").show();
	
	}else if(item=='3')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").show();
		$("#jydkRe").hide();
		$("#yisfAndEsfAddInfo").hide();
	
	}else if(item=='4')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").show();
		$("#yisfAndEsfAddInfo").hide();
	
	}else if(item=='5')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#yisfAndEsfAddInfo").hide();
	
	}*/
    if(businessTypeValue=='1')
	{
    	$("#ysfRe").show();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#syryRe").hide();
		$("#dmfbRe").hide();
		$("#yisfAndEsfAddInfo").show();
		$("#houseNumDiv").show();
		$("#addYsfRemark1").val(object.ysfRemark1);
		if(object.ysfRemark1=='1')
		{
			
			$("#yszfRe").show();
			$("#addYszfRemark2").val(object.yszfRemark2);
		}
		else if(object.ysfRemark1=='2')
		{
			$("#syfRe").show();
			$("#addSyfRemark2").val(object.syfRemark2);
			if(object.syfRemark2=='1')
			{
				$("#houseNumDiv").hide();
			}
		}
		$("#addArea").val(object.area);
		$("#addHouseAmount").val(object.houseAmount);
		$("#addHouseNum").val(object.houseNum);
		$("#addIncome").val(object.income);
		$("#addPayPerMonth").val(object.payPerMonth);
	}
	else if(businessTypeValue=='2')
	{
		$("#ysfRe").hide();
		$("#esfRe").show();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#syryRe").hide();
		$("#dmfbRe").hide();
		$("#yszfRe").hide();
		$("#syfRe").hide();
		
		$("#yisfAndEsfAddInfo").show();
		$("#houseNumDiv").show();
		$("#addEsfRemark").val(object.esfRemark);
		
		$("#addArea").val(object.area);
		$("#addHouseAmount").val(object.houseAmount);
		$("#addHouseNum").val(object.houseNum);
		$("#addIncome").val(object.income);
		$("#addPayPerMonth").val(object.payPerMonth);
	
	}else if(businessTypeValue=='3')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").show();
		$("#jydkRe").hide();
		$("#syryRe").hide();
		$("#dmfbRe").hide();
		$("#yszfRe").hide();
		$("#syfRe").hide();
		$("#yisfAndEsfAddInfo").hide();
		$("#houseNumDiv").hide();
		$("#addXfdkRemark").val(object.xfdkRemark);
		//$("#addJydkRemark2").val(object.jydkRemark2);
	
	}else if(businessTypeValue=='4')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").show();
		
		$("#yszfRe").hide();
		$("#syfRe").hide();
		
		$("#yisfAndEsfAddInfo").hide();
		$("#houseNumDiv").hide();
		$("#addJydkRemark1").val(object.jydkRemark1);
		if(object.jydkRemark1=='2')
		{
			$("#syryRe").show();
			$("#addSyryRemark2").val(object.syryRemark2);
		}
		else if(object.jydkRemark1=='3')
		{
			$("#dmfbRe").show();
			$("#addDmfbRemark2").val(object.dmfbRemark2);
		}
	
	}else if(businessTypeValue=='5')
	{
		$("#ysfRe").hide();
		$("#esfRe").hide();
		$("#xfdkRe").hide();
		$("#jydkRe").hide();
		$("#syryRe").hide();
		$("#dmfbRe").hide();
		$("#yszfRe").hide();
		$("#syfRe").hide();
		$("#yisfAndEsfAddInfo").hide();
		$("#houseNumDiv").hide();
//		$("#addEsfajRemark").val(object.esfajRemark);
	}
    
    
    $("#addAmount").val(object.amount);
	$("#addTerm").val(object.term);
	//$("#addGuaranteeMethod").val(object.guaranteeMethod);
	$("input[name='guaranteeMethod']").each(function(i){  
        if($(this).val()==object.guaranteeMethod)  
        {  
        	$(this).attr('checked','checked');
            $(this).parent('label').addClass('active');  
        }  
    });
	//$("#addIsRenew").val(object.isRenew);
	$("input[name='isRenew']").each(function(i){  
        if($(this).val()==object.isRenew)  
        {  
        	$(this).attr('checked','checked');
            $(this).parent('label').addClass('active');  
        }  
    });
	$("#addMarketer").val(object.marketer);
	$("#addMarketerPost").val(object.marketerPost);
	$("#addOperator").val(object.operator);
	$("#addOperatorPost").val(object.operatorPost);
	
	$("#addRepaymentMethod").val(object.repaymentMethod);
	$("#addRecieveTime").val(object.recieveTime);
	
	if(nowOperate=="supply")
	{
		//缺少材料提示 jkrqscl
		var jkrqsclList=object.jkrqscl;
		if(jkrqsclList!=null&&jkrqsclList.length>0)
		{
			var jkrTips="缺少借款人所需材料：";
			for(var i=0;i<jkrqsclList.length;i++)
			{
				jkrTips+="【"+jkrqsclList[i]+"】；";
			}
			$("#jkrqs").show();
			$("#jkrqs").html(jkrTips);
		}
		else{
			$("#jkrqs").hide();
		}
		
		var dbrqsclList=object.dbrqscl;
		if(dbrqsclList!=null&&dbrqsclList.length>0)
		{
			var dbrTips="缺少担保人所需材料：";
			for(var i=0;i<dbrqsclList.length;i++)
			{
				dbrTips+="【"+dbrqsclList[i]+"】；";
			}
			$("#dbrqs").show();
			$("#dbrqs").html(dbrTips);
		}
		else{
			$("#dbrqs").hide();
		}
		
		var qtbcclList=object.qtbc;
		if(qtbcclList!=null&&qtbcclList!="")
		{
			var qtbcTips="其他补充内容：";
			$("#qtbc").show();
			$("#qtbc").html(qtbcTips+qtbcclList);
		}
		else{
			$("#qtbc").hide();
		}
		
		var qtqsclList=object.qtqscl;
		if(qtqsclList!=null&&qtqsclList.length>0)
		{
			var qtTips="缺少贷款其他所需资料：";
			for(var i=0;i<qtqsclList.length;i++)
			{
				qtTips+="【"+qtqsclList[i]+"】；";
			}
			$("#qtqs").show();
			$("#qtqs").html(qtTips);
		}
		else{
			$("#qtqs").hide();
		}
	}
	
	
	store_old['borrowerName']=object.borrowerName;
	store_old['isMaryed']=object.isMaryed;
	if(addIsMaryed=="是")
	{
		store_old['spouseName']=object.spouseName;
		store_old['spouseCredentialNo']=object.spouseCredentialNo;
	}
	
	store_old['sex']=object.sex;
	store_old['credentialNo']=object.credentialNo;
	store_old['businessType']=object.businessTypes;
	
	store_old['ysfRemark1']=object.ysfRemark1;
	store_old['yszfRemark2']=object.yszfRemark2;
	store_old['syfRemark2']=object.syfRemark2;
	store_old['area']=object.area;
	store_old['houseAmount']=object.houseAmount;
	store_old['houseNum']=object.houseNum;
	store_old['income']=object.income;
	store_old['payPerMonth']=object.payPerMonth;
	store_old['esfRemark']=object.esfRemark;
	store_old['xfdkRemark']=object.xfdkRemark;
	store_old['jydkRemark1']=object.jydkRemark1;
	store_old['syryRemark2']=object.syryRemark2;
	store_old['dmfbRemark2']=object.dmfbRemark2;
	
	store_old['amount']=object.amount;
	store_old['term']=object.term;
	store_old['guaranteeMethod']=object.guaranteeMethod;
	store_old['isRenew']=object.isRenew;
	store_old['marketer']=object.marketer;
	store_old['marketerPost']=object.marketerPost;
	store_old['operator']=object.operator;
	store_old['operatorPost']=object.operatorPost;
	store_old['receiveTime']=object.recieveTime;
	store_old['repaymentMethod']=object.repaymentMethod;
};


/**
 *将json字符串转化为json对象
 */
function str2Json(jsonStr){
	var json = eval("(" + jsonStr + ")"); 
	return json;
};
